use uniform header guards in jeeps. (#1216)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Tue, 14 Nov 2023 14:36:58 +0000 (07:36 -0700)
committerGitHub <noreply@github.com>
Tue, 14 Nov 2023 14:36:58 +0000 (07:36 -0700)
and
delete an obsolete prototype.
rename jgpsutil.cc now that it doesn't conflict with a format.

22 files changed:
CMakeLists.txt
jeeps/garminusb.h
jeeps/gps.h
jeeps/gpsapp.h
jeeps/gpscom.h
jeeps/gpsdatum.h
jeeps/gpsdevice.h
jeeps/gpsfmt.h
jeeps/gpsmath.h
jeeps/gpsmem.h
jeeps/gpsport.h
jeeps/gpsproj.h
jeeps/gpsprot.h
jeeps/gpsread.h
jeeps/gpsrqst.h
jeeps/gpssend.h
jeeps/gpsserial.h
jeeps/gpsusbcommon.h
jeeps/gpsusbint.h
jeeps/gpsutil.cc [new file with mode: 0644]
jeeps/gpsutil.h
jeeps/jgpsutil.cc [deleted file]

index fcbb1dc2068e07435b6efd1b277bbe34afc676b9..c664f0ed8bc7c7c04f08fadc7d51164684c25f6e 100644 (file)
@@ -153,7 +153,7 @@ set(JEEPS
   jeeps/gpsusbcommon.cc
   jeeps/gpsusbread.cc
   jeeps/gpsusbsend.cc
-  jeeps/jgpsutil.cc
+  jeeps/gpsutil.cc
 )
 
 # SUPPORT
index 5e968d655fa2ca8ba010982018b523eab9b02b5f..41e9a9447bd8b60fb077c8536e4934a0ccc57cf8 100644 (file)
@@ -18,6 +18,9 @@
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
  */
+#ifndef JEEPS_GARMINUSB_H_INCLUDED_
+#define JEEPS_GARMINUSB_H_INCLUDED_
+
 #include <cstdio>
 #include "jeeps/gpsdevice.h"
 
@@ -68,3 +71,5 @@ int gusb_close(gpsdevh* dh, bool exit_lib = true);
 #define GUSB_SESSION_START 5   /* We request units attention */
 #define GUSB_SESSION_ACK   6   /* Unit responds that we have its attention */
 #define GUSB_REQUEST_BULK  2   /* Unit requests we read from bulk pipe */
+
+#endif // JEEPS_GARMINUSB_H_INCLUDED_
index f9e9f54840c85f0f7f887ad7ede1ed6bdec16972..a3701a998ed026372f3c0eaeae9f392db270926e 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef gps_h
-#define gps_h
+#ifndef JEEPS_GPS_H_INCLUDED_
+#define JEEPS_GPS_H_INCLUDED_
 
 #include "defs.h"
 #include "jeeps/gpsport.h"
@@ -265,4 +265,4 @@ extern const char* gps_aviation_sym[];
 extern const char* gps_16_sym[];
 
 
-#endif
+#endif // JEEPS_GPS_H_INCLUDED_
index ee03d78de1310daeb4e146092bf8be0ec2694513..12b33a211fc48e1e65dd9250152a4b229378a228 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef gpsapp_h
-#define gpsapp_h
+#ifndef JEEPS_GPSAPP_H_INCLUDED_
+#define JEEPS_GPSAPP_H_INCLUDED_
 
 
 #include "jeeps/gps.h"
   void GPS_Prepare_Track_For_Device(GPS_PTrack** trk, int32* n);
   int32 GPS_Set_Baud_Rate(const char* port, int br);
 
-#endif
+#endif // JEEPS_GPSAPP_H_INCLUDED_
index 53ece39b7709191ce4523fadef0fdd7ccf136196..c8cc2580602cfc2f31a13745b461c1e13e3613ae 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef gpscom_h
-#define gpscom_h
+#ifndef JEEPS_GPSCOM_H_INCLUDED_
+#define JEEPS_GPSCOM_H_INCLUDED_
 
 
 #include "jeeps/gps.h"
@@ -44,4 +44,4 @@
   int32  GPS_Command_Get_Fitness_User_Profile(const char* port, void** lap, int (*cb)(int, GPS_SWay**));
   int32  GPS_Command_Get_Workout_Limits(const char* port, void** lap, int (*cb)(int, GPS_SWay**));
   int32  GPS_Command_Get_Course_Limits(const char* port, void** lap, int (*cb)(int, GPS_SWay**));
-#endif
+#endif // JEEPS_GPSCOM_H_INCLUDED_
index c59f7977ee252604003260c6c0596ece3df434b4..4444797ddfef2f429f3e1941a5a4305720e51960 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef gpsdatum_h
-#define gpsdatum_h
+#ifndef JEEPS_GPSDATUM_H_INCLUDED_
+#define JEEPS_GPSDATUM_H_INCLUDED_
 
 
 
 
 
 
-#endif
+#endif // JEEPS_GPSDATUM_H_INCLUDED_
index f893adf274c6ae55fed7062ae9f5c5c5cf78bc06..5abf56b0a7f9b656901473b6776129c4b399a143 100644 (file)
@@ -19,8 +19,8 @@
 
  */
 
-#ifndef gpsdevice_h
-#define gpsdevice_h
+#ifndef JEEPS_GPSDEVICE_H_INCLUDED_
+#define JEEPS_GPSDEVICE_H_INCLUDED_
 
   typedef struct gpsdevh gpsdevh;
 
@@ -60,4 +60,4 @@
     gps_device_op12 Write_Packet;
   } gps_device_ops;
 
-#endif /* gpsdevice_h */
+#endif /* JEEPS_GPSDEVICE_H_INCLUDED_ */
index cbaad086d6ae085366863b2673e9789c5842d193..3cf101690ac879e2c10f9c666361fb2a64dfe376 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef gpsfmt_h
-#define gpsfmt_h
+#ifndef JEEPS_GPSFMT_H_INCLUDED_
+#define JEEPS_GPSFMT_H_INCLUDED_
 
 
 #include "jeeps/gps.h"
@@ -15,4 +15,4 @@
   int32  GPS_Fmt_Print_Proximity(GPS_PWay* way, int32 n, FILE* outf);
   int32  GPS_Fmt_Print_Route(GPS_PWay* way, int32 n, FILE* outf);
 
-#endif
+#endif // JEEPS_GPSFMT_H_INCLUDED_
index 36d78436d213ce83c2c224eaef487dcb001d07b5..fa35c1ce0b5dd5ec8d4b0bd96405de836429f79d 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef gpsmath_h
-#define gpsmath_h
+#ifndef JEEPS_GPSMATH_H_INCLUDED_
+#define JEEPS_GPSMATH_H_INCLUDED_
 
 #include "jeeps/gpsport.h"
 
   int32 GPS_Lookup_Datum_Index(const QString& n);
   const char* GPS_Math_Get_Datum_Name(int datum_index);
 
-#endif
+#endif // JEEPS_GPSMATH_H_INCLUDED_
index 5d29231e14663ec95f3f15c038f021fc75adcd97..01038d9fa58a8c21da39f1f07b56b718d4705064 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef gpsmem_h
-#define gpsmem_h
+#ifndef JEEPS_GPSMEM_H_INCLUDED_
+#define JEEPS_GPSMEM_H_INCLUDED_
 
 
 #include "jeeps/gps.h"
@@ -20,4 +20,4 @@
   GPS_PCourse_Point GPS_Course_Point_New();
   void              GPS_Course_Point_Del(GPS_PCourse_Point* thys);
 
-#endif
+#endif // JEEPS_GPSMEM_H_INCLUDED_
index 3fac996ee498e1770e46d7c70a129d984788a990..3646a3e67e18206f4d4184af8409661bb3c42539 100644 (file)
@@ -7,9 +7,17 @@
  * defs.h includes gbtypes.h before this file, just use that.
  */
 
+#ifndef JEEPS_GPSPORT_H_INCLUDED_
+#define JEEPS_GPSPORT_H_INCLUDED_
+
+#include <cstdint>
+
+
 typedef unsigned char UC;
 typedef uint16_t      US;
 typedef uint16_t      uint16;
 typedef int16_t       int16;
 typedef uint32_t      uint32;
 typedef int32_t       int32;
+
+#endif // JEEPS_GPSPORT_H_INCLUDED_
index f76814560154b0312867480f0898d5a3c348953e..cbdca53dfd12e17b521e73d88e23bf38a70f1f56 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef gpsproj_h
-#define gpsproj_h
+#ifndef JEEPS_GPSPROJ_H_INCLUDED_
+#define JEEPS_GPSPROJ_H_INCLUDED_
 
 
 #include "jeeps/gps.h"
                                    double* lambda, double phi0, double lambda0,
                                    double E0, double N0, double a, double b);
 
-#endif
+#endif // JEEPS_GPSPROJ_H_INCLUDED_
index e16600fdf866c5cac5b5053e1c3cd1f1cbab7763..5a2a3cc6c1f302506e41d7ceafe820fef4caa739 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef gpsprotocols_h
-#define gpsprotocols_h
+#ifndef JEEPS_GPSPROT_H_INCLUDED_
+#define JEEPS_GPSPROT_H_INCLUDED_
 
 #ifndef COMMON
 #define COMMON extern
@@ -90,8 +90,7 @@
     US Cmnd_Transfer_Course_Points;
     US Cmnd_Transfer_Course_Tracks;
     US Cmnd_Transfer_Course_Limits;
-  }
-  ;
+  };
 
 
 
     int32 prxd;
     int32 alma;
     int32 almd;
-  }
-  ;
+  };
 
   US     GPS_Protocol_Version_Change(US id, US version);
   COMMON int32  GPS_Protocol_Table_Set(US id);
   void   GPS_Unknown_Protocol_Print();
 
 
-#endif
+#endif // JEEPS_GPSPROT_H_INCLUDED_
index d8461ac228a3b5812ed2f5c8e1c062e5318fb309..6bee1e7abf54e67ec510623c7ed96e9de2ea76e8 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef gpsread_h
-#define gpsread_h
+#ifndef JEEPS_GPSREAD_H_INCLUDED_
+#define JEEPS_GPSREAD_H_INCLUDED_
 
 
 #include "jeeps/gps.h"
@@ -8,4 +8,4 @@
   int32  GPS_Serial_Packet_Read(gpsdevh* fd, GPS_Packet* packet);
   bool GPS_Serial_Get_Ack(gpsdevh *fd, GPS_Packet *tra, GPS_Packet *rec);
 
-#endif
+#endif // JEEPS_GPSREAD_H_INCLUDED_
index ad05722d6843da3bde1486207f2e92f2d9c44327..c97e013548ac1339d4fc2b14a0f62174497f6460 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef gpsrqst_h
-#define gpsrqst_h
+#ifndef JEEPS_GPSRQST_H_INCLUDED_
+#define JEEPS_GPSRQST_H_INCLUDED_
 
 
 #include "jeeps/gps.h"
@@ -8,4 +8,4 @@
   int32 GPS_Rqst_Send_Position(gpsdevh* fd, double lat, double lon);
 
 
-#endif
+#endif // JEEPS_GPSRQST_H_INCLUDED_
index c478e9880242f3bf384fda5da81af1bd6e37b3ab..3f3b12e8d35d47b76b7df9b83901bc6d1220c6b6 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef gpssend_h
-#define gpssend_h
+#ifndef JEEPS_GPSSEND_H_INCLUDED_
+#define JEEPS_GPSSEND_H_INCLUDED_
 
 
 #include "jeeps/gps.h"
@@ -12,4 +12,4 @@
   void   GPS_Make_Packet(GPS_Packet* packet, US type, UC* data, uint32 n);
 
 
-#endif
+#endif // JEEPS_GPSSEND_H_INCLUDED_
index f5eba487d1c8ea9609ba4092c8be6d8796b70bd4..c960234d373dc8c3be0d675bd9aff740bf3ef301 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef gpsserial_h
-#define gpsserial_h
+#ifndef JEEPS_GPSSERIAL_H_INCLUDED_
+#define JEEPS_GPSSERIAL_H_INCLUDED_
 
 
 #include "jeeps/gps.h"
@@ -24,4 +24,4 @@
 
 int32  GPS_Serial_Set_Baud_Rate(gpsdevh* fd, int br);
 
-#endif
+#endif // JEEPS_GPSSERIAL_H_INCLUDED_
index d1745679933e492772a37d0dbac77d86b1cccfd0..22f587f1a0c4cc61a47d81644fdc85c6b55aa73e 100644 (file)
@@ -19,6 +19,9 @@
 
  */
 
+#ifndef JEEPS_GPSUSBCOMMON_H_INCLUDED_
+#define JEEPS_GPSUSBCOMMON_H_INCLUDED_
+
 /*
  * The 'low level ops' are registered by the OS layer (win32, libusb, etc.)
  * to provide gruntwork features for the common USB layer.
@@ -43,3 +46,4 @@ void gusb_list_units();
 /* Provided by the OS layers */
 // int gusb_init(const char *portname, gpsdev **dh);
 
+#endif // JEEPS_GPSUSBCOMMON_H_INCLUDED_
index cba2bee1cfe13da5c0651af322698b195df1b6cf..2e557d1c57d5c1cbfde1250127e749ae4c82e6a6 100644 (file)
 
  */
 
+#ifndef JEEPS_GPSUSBINT_H_INCLUDED_
+#define JEEPS_GPSUSBINT_H_INCLUDED_
+
 int32 GPS_Packet_Read_usb(gpsdevh* fd, GPS_Packet* packet, int eatbulk);
-void  GPS_Make_Packet_usb(GPS_Packet* packet, UC type, UC* data, int16 n);
 int32 GPS_Write_Packet_usb(gpsdevh* fd, const GPS_Packet& packet);
 
+#endif // JEEPS_GPSUSBINT_H_INCLUDED_
+
diff --git a/jeeps/gpsutil.cc b/jeeps/gpsutil.cc
new file mode 100644 (file)
index 0000000..68c5f92
--- /dev/null
@@ -0,0 +1,693 @@
+/********************************************************************
+** @source JEEPS utility functions
+**
+** @author Copyright (C) 1999 Alan Bleasby
+** @version 1.0
+** @modified Dec 28 1999 Alan Bleasby. First version
+** @@
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Library General Public
+** License as published by the Free Software Foundation; either
+** version 2 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+** Library General Public License for more details.
+**
+** You should have received a copy of the GNU Library General Public
+** License along with this library; if not, write to the
+** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+** Boston, MA  02110-1301, USA.
+********************************************************************/
+#include "jeeps/gps.h"
+#include <cstdarg>
+#include <cstdlib>
+#include <fcntl.h>
+
+static int32 gps_endian_called=0;
+static int32 GPS_Little=0;
+
+int32 gps_warning = 0;
+int32 gps_error   = 0;
+int32 gps_user    = 0;
+int32 gps_show_bytes = 0;
+int32 gps_errno = 0;
+
+/* @func GPS_Util_Little ***********************************************
+**
+** Determine endian nature of host
+**
+** @return [int32] true if little-endian
+************************************************************************/
+
+int32 GPS_Util_Little()
+{
+  static union lb {
+    char chars[sizeof(int32)];
+    int32 i;
+  }
+  data;
+
+  if (!gps_endian_called) {
+    gps_endian_called = 1;
+    data.i = 0;
+    *data.chars = '\1';
+    if (data.i == 1) {
+      GPS_Little = 1;
+    } else {
+      GPS_Little = 0;
+    }
+  }
+
+  return GPS_Little;
+}
+
+
+/* @func GPS_Util_Get_Short ********************************************
+**
+** Get a short from a string
+**
+** @return [US] value
+************************************************************************/
+
+US GPS_Util_Get_Short(const UC* s)
+{
+  static US ret;
+  UC* p;
+
+  p = (UC*)&ret;
+
+  if (!GPS_Little) {
+    *p++ = *(s+1);
+    *p = *s;
+  } else {
+    *p++ = *s;
+    *p = *(s+1);
+  }
+
+  return ret;
+}
+
+
+
+/* @func GPS_Util_Put_Short ********************************************
+**
+** Put a short to a string
+**
+** @param [w] s [UC *] string to write to
+** @param [r] v [const US] short to write
+**
+** @return [void]
+************************************************************************/
+
+void GPS_Util_Put_Short(UC* s, const US v)
+{
+  const auto* p = reinterpret_cast<const UC*>(&v);
+
+  if (!GPS_Little) {
+    *s++ = *(p+1);
+    *s = *p;
+  } else {
+    *s++ = *p;
+    *s = *(p+1);
+  }
+
+  return;
+}
+
+
+
+/* @func GPS_Util_Get_Double ********************************************
+**
+** Get a double from a string
+**
+** @return [double] value
+************************************************************************/
+
+double GPS_Util_Get_Double(const UC* s)
+{
+  double ret;
+  UC* p;
+  int32 i;
+
+  p = (UC*)&ret;
+
+
+  if (!GPS_Little)
+    for (i=sizeof(double)-1; i>-1; --i) {
+      *p++ = s[i];
+    }
+  else
+    for (i=0; i<(int32)sizeof(double); ++i) {
+      *p++ = s[i];
+    }
+
+  return ret;
+}
+
+
+
+/* @func GPS_Util_Put_Double ********************************************
+**
+** Put a double to a string
+**
+** @param [w] s [UC *] string to write to
+** @param [r] v [const double] double to write
+**
+** @return [void]
+************************************************************************/
+
+void GPS_Util_Put_Double(UC* s, const double v)
+{
+  int32 i;
+
+  const auto* p = reinterpret_cast<const UC*>(&v);
+
+  if (!GPS_Little)
+    for (i=sizeof(double)-1; i>-1; --i) {
+      s[i] = *p++;
+    }
+  else
+    for (i=0; i<(int32)sizeof(double); ++i) {
+      s[i] = *p++;
+    }
+
+  return;
+}
+
+
+
+
+/* @func GPS_Util_Get_Int ********************************************
+**
+** Get an int from a string
+**
+** @return [int32] value
+************************************************************************/
+
+int32 GPS_Util_Get_Int(const UC* s)
+{
+  int32 ret;
+  UC* p;
+  int32 i;
+
+  p = (UC*)&ret;
+
+
+  if (!GPS_Little)
+    for (i=sizeof(int32)-1; i>-1; --i) {
+      *p++ = s[i];
+    }
+  else
+    for (i=0; i<(int32)sizeof(int32); ++i) {
+      *p++ = s[i];
+    }
+
+  return ret;
+}
+
+
+
+/* @func GPS_Util_Put_Int ********************************************
+**
+** Put a int to a string
+**
+** @param [w] s [UC *] string to write to
+** @param [r] v [const int32] int to write
+**
+** @return [void]
+************************************************************************/
+
+void GPS_Util_Put_Int(UC* s, const int32 v)
+{
+  int32 i;
+
+  const auto* p = reinterpret_cast<const UC*>(&v);
+
+  if (!GPS_Little)
+    for (i=sizeof(int32)-1; i>-1; --i) {
+      s[i] = *p++;
+    }
+  else
+    for (i=0; i<(int32)sizeof(int32); ++i) {
+      s[i] = *p++;
+    }
+
+  return;
+}
+
+
+
+/* @func GPS_Util_Get_Uint ********************************************
+**
+** Get an unsigned int from a string
+**
+** @return [uint32] value
+************************************************************************/
+
+uint32 GPS_Util_Get_Uint(const UC* s)
+{
+  uint32 ret;
+  UC*     p;
+  int32  i;
+
+  p = (UC*)&ret;
+
+
+  if (!GPS_Little)
+    for (i=sizeof(uint32)-1; i>-1; --i) {
+      *p++ = s[i];
+    }
+  else
+    for (i=0; i<(int32)sizeof(uint32); ++i) {
+      *p++ = s[i];
+    }
+
+  return ret;
+}
+
+
+
+/* @func GPS_Util_Put_Uint ********************************************
+**
+** Put an unsigned int to a string
+**
+** @param [w] s [UC *] string to write to
+** @param [r] v [const uint32] unsigned int to write
+**
+** @return [void]
+************************************************************************/
+
+void GPS_Util_Put_Uint(UC* s, const uint32 v)
+{
+  int32 i;
+
+  const auto* p = reinterpret_cast<const UC*>(&v);
+
+  if (!GPS_Little)
+    for (i=sizeof(uint32)-1; i>-1; --i) {
+      s[i] = *p++;
+    }
+  else
+    for (i=0; i<(int32)sizeof(uint32); ++i) {
+      s[i] = *p++;
+    }
+
+  return;
+}
+
+
+
+/* @func GPS_Util_Get_Float ********************************************
+**
+** Get a float from a string
+**
+** @return [float] value
+************************************************************************/
+
+float GPS_Util_Get_Float(const UC* s)
+{
+  float ret;
+  UC* p;
+  int32 i;
+
+  p = (UC*)&ret;
+
+
+  if (!GPS_Little)
+    for (i=sizeof(float)-1; i>-1; --i) {
+      *p++ = s[i];
+    }
+  else
+    for (i=0; i<(int32)sizeof(float); ++i) {
+      *p++ = s[i];
+    }
+
+  return ret;
+}
+
+
+
+/* @func GPS_Util_Put_Float ********************************************
+**
+** Put a float to a string
+**
+** @param [w] s [UC *] string to write to
+** @param [r] v [const float] float to write
+**
+** @return [void]
+************************************************************************/
+
+void GPS_Util_Put_Float(UC* s, const float v)
+{
+  int32 i;
+
+  const auto* p = reinterpret_cast<const UC*>(&v);
+
+  if (!GPS_Little)
+    for (i=sizeof(float)-1; i>-1; --i) {
+      s[i] = *p++;
+    }
+  else
+    for (i=0; i<(int32)sizeof(float); ++i) {
+      s[i] = *p++;
+    }
+
+  return;
+}
+
+#if 0
+/* @func GPS_Util_Canon  ****************************************************
+**
+** Sets or unsets canonical mode
+** NB: Must have called this with True before calling with False
+** NB: Remember to trun it off (false) eventually
+**
+** @param [r] state [int32] state=true->raw state=false->normal
+** @return [void]
+** @@
+****************************************************************************/
+
+void GPS_Util_Canon(int32 state)
+{
+  static struct termios tty;
+  static struct termios sv;
+
+
+  if (state) {
+    tcgetattr(1,&sv);
+    tcgetattr(1, &tty);
+    tty.c_cc[VMIN]='\1';
+    tty.c_cc[VTIME]='\0';
+    tcsetattr(1,TCSANOW,&tty);
+    tty.c_lflag &= ~(ICANON | ECHO);
+    tcsetattr(1, TCSANOW, &tty);
+  } else {
+    tcsetattr(1, TCSANOW, &sv);
+  }
+
+  return;
+}
+#endif
+
+#if 0
+/* @func GPS_Util_Block  ****************************************************
+**
+** Sets or unsets blocking
+** @modified 13-01-2000 to return an int
+**
+** @param [r] fd [int32] file descriptor
+** @param [r] state [int32] state=true->block state=false->non-block
+**
+** @return [int32] success
+** @@
+****************************************************************************/
+
+int32 GPS_Util_Block(int32 fd, int32 state)
+{
+  static int32 notcalled=1;
+  static int32 block;
+  static int32 noblock;
+  int32    f;
+
+  gps_errno = HARDWARE_ERROR;
+
+  if (notcalled) {
+    notcalled = 0;
+    if ((f=fcntl(fd,F_GETFL,0))==-1) {
+      GPS_Error("Util_Block: FCNTL error");
+      return 0;
+    }
+    block = f & ~O_NDELAY;
+    noblock = f |  O_NDELAY;
+  }
+
+  if (state) {
+    if (fcntl(fd,F_SETFL,block)==-1) {
+      GPS_Error("Util_Block: Error blocking");
+      return 0;
+    }
+  } else {
+    if (fcntl(fd,F_SETFL,noblock)==-1) {
+      GPS_Error("Util_Block: Error unblocking");
+      return 0;
+    }
+  }
+
+  return 1;
+}
+#endif
+
+
+/* @func GPS_Warning ********************************************************
+**
+** Prints warning if gps_warning is true
+**
+** @param [r] s [char *] warning
+**
+** @return [void]
+** @@
+****************************************************************************/
+
+void GPS_Warning(const char* s)
+{
+  if (!gps_warning) {
+    return;
+  }
+
+  fprintf(stderr,"[WARNING] %s\n",s);
+  fflush(stderr);
+
+  return;
+}
+
+
+/* @func GPS_Fatal ********************************************************
+**
+** Always prints error and exits program
+** Bad thing for a library so the library doesn't call it.
+**
+** @param [r] s [char *] fatal error
+**
+** @return [void]
+** @@
+****************************************************************************/
+
+[[noreturn]] void GPS_Fatal(const char* s)
+{
+
+  fprintf(stderr,"[FATAL] %s\n",s);
+  exit(0);
+}
+
+
+
+/* @func GPS_Error **********************************************************
+**
+** Prints Error if gps_error is true
+**
+** @param [r] s [char *] error
+**
+** @return [void]
+** @@
+****************************************************************************/
+
+void GPS_Error(const char* fmt, ...)
+{
+  va_list argp;
+  va_start(argp, fmt);
+
+  if (gps_error) {
+    fprintf(stderr, "[ERROR] ");
+    vfprintf(stderr, fmt, argp);
+    fprintf(stderr, "\n");
+  }
+
+  va_end(argp);
+  return;
+}
+
+
+/* @func GPS_Enable_Error ***************************************************
+**
+** Enable error message printing
+**
+** @return [void]
+** @@
+****************************************************************************/
+
+void GPS_Enable_Error()
+{
+  gps_error = 1;
+  return;
+}
+
+
+
+/* @func GPS_Enable_Warning ***************************************************
+**
+** Enable warning message printing
+**
+** @return [void]
+** @@
+****************************************************************************/
+
+void GPS_Enable_Warning()
+{
+  gps_warning = 1;
+  return;
+}
+
+
+
+/* @func GPS_Disable_Error ***************************************************
+**
+** Disable error message printing
+**
+** @return [void]
+** @@
+****************************************************************************/
+
+void GPS_Disable_Error()
+{
+  gps_error = 0;
+  return;
+}
+
+
+
+/* @func GPS_Disable_Warning ***********************************************
+**
+** Disable warning message printing
+**
+** @return [void]
+** @@
+****************************************************************************/
+
+void GPS_Disable_Warning()
+{
+  gps_warning = 0;
+  return;
+}
+
+
+
+/* @func GPS_User ********************************************************
+**
+** Prints a message if gps_user is true
+**
+** @param [r] s [char *] message
+**
+** @return [void]
+** @@
+****************************************************************************/
+
+void GPS_User(const char* fmt, ...)
+{
+  va_list  argp;
+  va_start(argp, fmt);
+
+  if (gps_user) {
+    vfprintf(stdout, fmt, argp);
+    fflush(stdout);
+  }
+
+  va_end(argp);
+}
+
+/* @func GPS_Disable_User ***********************************************
+**
+** Disable message printing
+**
+** @return [void]
+** @@
+****************************************************************************/
+
+void GPS_Disable_User()
+{
+  gps_user = 0;
+  return;
+}
+
+
+/* @func GPS_Enable_User ***********************************************
+**
+** Disable warning message printing
+**
+** @return [void]
+** @@
+****************************************************************************/
+
+void GPS_Enable_User()
+{
+  gps_user = 1;
+  return;
+}
+
+
+/* @func GPS_Diagnose ********************************************************
+**
+** Prints bytes read from gps if gps_show_bytes is set
+**
+** @param [r] cs [int32] byte read
+**
+** @return [void]
+** @@
+****************************************************************************/
+
+void GPS_Diagnose(int32 c)
+{
+  if (!gps_show_bytes) {
+    return;
+  }
+
+  fprintf(stdout,"%d\n",(int)c);
+  fflush(stdout);
+
+  return;
+}
+
+void GPS_Diag(const char* fmt, ...)
+{
+  va_list argp;
+  va_start(argp, fmt);
+
+  if (gps_show_bytes) {
+    vfprintf(stdout, fmt, argp);
+  }
+  va_end(argp);
+  return;
+
+}
+
+/* @func GPS_Enable_Diagnose ***********************************************
+**
+** Enable diagnosis mode
+**
+** @return [void]
+** @@
+****************************************************************************/
+
+void GPS_Enable_Diagnose()
+{
+  gps_show_bytes = 1;
+  return;
+}
+
+
+
+/* @func GPS_Disable_Diagnose ***********************************************
+**
+** Disable diagnosis mode
+**
+** @return [void]
+** @@
+****************************************************************************/
+
+void GPS_Disable_Diagnose()
+{
+  gps_show_bytes = 0;
+  return;
+}
index 55ec8b0ba21ec38cb294da25cd32829e211b15f0..212742833a846138a9fd631da35a76d43dfbad4a 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef gpsutil_h
-#define gpsutil_h
+#ifndef JEEPS_GPSUTIL_H_INCLUDED_
+#define JEEPS_GPSUTIL_H_INCLUDED_
 
 
 #include "jeeps/gps.h"
@@ -37,4 +37,4 @@
   void   GPS_Disable_Diagnose();
 
 
-#endif
+#endif // JEEPS_GPSUTIL_H_INCLUDED_
diff --git a/jeeps/jgpsutil.cc b/jeeps/jgpsutil.cc
deleted file mode 100644 (file)
index 68c5f92..0000000
+++ /dev/null
@@ -1,693 +0,0 @@
-/********************************************************************
-** @source JEEPS utility functions
-**
-** @author Copyright (C) 1999 Alan Bleasby
-** @version 1.0
-** @modified Dec 28 1999 Alan Bleasby. First version
-** @@
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Library General Public
-** License as published by the Free Software Foundation; either
-** version 2 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-** Library General Public License for more details.
-**
-** You should have received a copy of the GNU Library General Public
-** License along with this library; if not, write to the
-** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-** Boston, MA  02110-1301, USA.
-********************************************************************/
-#include "jeeps/gps.h"
-#include <cstdarg>
-#include <cstdlib>
-#include <fcntl.h>
-
-static int32 gps_endian_called=0;
-static int32 GPS_Little=0;
-
-int32 gps_warning = 0;
-int32 gps_error   = 0;
-int32 gps_user    = 0;
-int32 gps_show_bytes = 0;
-int32 gps_errno = 0;
-
-/* @func GPS_Util_Little ***********************************************
-**
-** Determine endian nature of host
-**
-** @return [int32] true if little-endian
-************************************************************************/
-
-int32 GPS_Util_Little()
-{
-  static union lb {
-    char chars[sizeof(int32)];
-    int32 i;
-  }
-  data;
-
-  if (!gps_endian_called) {
-    gps_endian_called = 1;
-    data.i = 0;
-    *data.chars = '\1';
-    if (data.i == 1) {
-      GPS_Little = 1;
-    } else {
-      GPS_Little = 0;
-    }
-  }
-
-  return GPS_Little;
-}
-
-
-/* @func GPS_Util_Get_Short ********************************************
-**
-** Get a short from a string
-**
-** @return [US] value
-************************************************************************/
-
-US GPS_Util_Get_Short(const UC* s)
-{
-  static US ret;
-  UC* p;
-
-  p = (UC*)&ret;
-
-  if (!GPS_Little) {
-    *p++ = *(s+1);
-    *p = *s;
-  } else {
-    *p++ = *s;
-    *p = *(s+1);
-  }
-
-  return ret;
-}
-
-
-
-/* @func GPS_Util_Put_Short ********************************************
-**
-** Put a short to a string
-**
-** @param [w] s [UC *] string to write to
-** @param [r] v [const US] short to write
-**
-** @return [void]
-************************************************************************/
-
-void GPS_Util_Put_Short(UC* s, const US v)
-{
-  const auto* p = reinterpret_cast<const UC*>(&v);
-
-  if (!GPS_Little) {
-    *s++ = *(p+1);
-    *s = *p;
-  } else {
-    *s++ = *p;
-    *s = *(p+1);
-  }
-
-  return;
-}
-
-
-
-/* @func GPS_Util_Get_Double ********************************************
-**
-** Get a double from a string
-**
-** @return [double] value
-************************************************************************/
-
-double GPS_Util_Get_Double(const UC* s)
-{
-  double ret;
-  UC* p;
-  int32 i;
-
-  p = (UC*)&ret;
-
-
-  if (!GPS_Little)
-    for (i=sizeof(double)-1; i>-1; --i) {
-      *p++ = s[i];
-    }
-  else
-    for (i=0; i<(int32)sizeof(double); ++i) {
-      *p++ = s[i];
-    }
-
-  return ret;
-}
-
-
-
-/* @func GPS_Util_Put_Double ********************************************
-**
-** Put a double to a string
-**
-** @param [w] s [UC *] string to write to
-** @param [r] v [const double] double to write
-**
-** @return [void]
-************************************************************************/
-
-void GPS_Util_Put_Double(UC* s, const double v)
-{
-  int32 i;
-
-  const auto* p = reinterpret_cast<const UC*>(&v);
-
-  if (!GPS_Little)
-    for (i=sizeof(double)-1; i>-1; --i) {
-      s[i] = *p++;
-    }
-  else
-    for (i=0; i<(int32)sizeof(double); ++i) {
-      s[i] = *p++;
-    }
-
-  return;
-}
-
-
-
-
-/* @func GPS_Util_Get_Int ********************************************
-**
-** Get an int from a string
-**
-** @return [int32] value
-************************************************************************/
-
-int32 GPS_Util_Get_Int(const UC* s)
-{
-  int32 ret;
-  UC* p;
-  int32 i;
-
-  p = (UC*)&ret;
-
-
-  if (!GPS_Little)
-    for (i=sizeof(int32)-1; i>-1; --i) {
-      *p++ = s[i];
-    }
-  else
-    for (i=0; i<(int32)sizeof(int32); ++i) {
-      *p++ = s[i];
-    }
-
-  return ret;
-}
-
-
-
-/* @func GPS_Util_Put_Int ********************************************
-**
-** Put a int to a string
-**
-** @param [w] s [UC *] string to write to
-** @param [r] v [const int32] int to write
-**
-** @return [void]
-************************************************************************/
-
-void GPS_Util_Put_Int(UC* s, const int32 v)
-{
-  int32 i;
-
-  const auto* p = reinterpret_cast<const UC*>(&v);
-
-  if (!GPS_Little)
-    for (i=sizeof(int32)-1; i>-1; --i) {
-      s[i] = *p++;
-    }
-  else
-    for (i=0; i<(int32)sizeof(int32); ++i) {
-      s[i] = *p++;
-    }
-
-  return;
-}
-
-
-
-/* @func GPS_Util_Get_Uint ********************************************
-**
-** Get an unsigned int from a string
-**
-** @return [uint32] value
-************************************************************************/
-
-uint32 GPS_Util_Get_Uint(const UC* s)
-{
-  uint32 ret;
-  UC*     p;
-  int32  i;
-
-  p = (UC*)&ret;
-
-
-  if (!GPS_Little)
-    for (i=sizeof(uint32)-1; i>-1; --i) {
-      *p++ = s[i];
-    }
-  else
-    for (i=0; i<(int32)sizeof(uint32); ++i) {
-      *p++ = s[i];
-    }
-
-  return ret;
-}
-
-
-
-/* @func GPS_Util_Put_Uint ********************************************
-**
-** Put an unsigned int to a string
-**
-** @param [w] s [UC *] string to write to
-** @param [r] v [const uint32] unsigned int to write
-**
-** @return [void]
-************************************************************************/
-
-void GPS_Util_Put_Uint(UC* s, const uint32 v)
-{
-  int32 i;
-
-  const auto* p = reinterpret_cast<const UC*>(&v);
-
-  if (!GPS_Little)
-    for (i=sizeof(uint32)-1; i>-1; --i) {
-      s[i] = *p++;
-    }
-  else
-    for (i=0; i<(int32)sizeof(uint32); ++i) {
-      s[i] = *p++;
-    }
-
-  return;
-}
-
-
-
-/* @func GPS_Util_Get_Float ********************************************
-**
-** Get a float from a string
-**
-** @return [float] value
-************************************************************************/
-
-float GPS_Util_Get_Float(const UC* s)
-{
-  float ret;
-  UC* p;
-  int32 i;
-
-  p = (UC*)&ret;
-
-
-  if (!GPS_Little)
-    for (i=sizeof(float)-1; i>-1; --i) {
-      *p++ = s[i];
-    }
-  else
-    for (i=0; i<(int32)sizeof(float); ++i) {
-      *p++ = s[i];
-    }
-
-  return ret;
-}
-
-
-
-/* @func GPS_Util_Put_Float ********************************************
-**
-** Put a float to a string
-**
-** @param [w] s [UC *] string to write to
-** @param [r] v [const float] float to write
-**
-** @return [void]
-************************************************************************/
-
-void GPS_Util_Put_Float(UC* s, const float v)
-{
-  int32 i;
-
-  const auto* p = reinterpret_cast<const UC*>(&v);
-
-  if (!GPS_Little)
-    for (i=sizeof(float)-1; i>-1; --i) {
-      s[i] = *p++;
-    }
-  else
-    for (i=0; i<(int32)sizeof(float); ++i) {
-      s[i] = *p++;
-    }
-
-  return;
-}
-
-#if 0
-/* @func GPS_Util_Canon  ****************************************************
-**
-** Sets or unsets canonical mode
-** NB: Must have called this with True before calling with False
-** NB: Remember to trun it off (false) eventually
-**
-** @param [r] state [int32] state=true->raw state=false->normal
-** @return [void]
-** @@
-****************************************************************************/
-
-void GPS_Util_Canon(int32 state)
-{
-  static struct termios tty;
-  static struct termios sv;
-
-
-  if (state) {
-    tcgetattr(1,&sv);
-    tcgetattr(1, &tty);
-    tty.c_cc[VMIN]='\1';
-    tty.c_cc[VTIME]='\0';
-    tcsetattr(1,TCSANOW,&tty);
-    tty.c_lflag &= ~(ICANON | ECHO);
-    tcsetattr(1, TCSANOW, &tty);
-  } else {
-    tcsetattr(1, TCSANOW, &sv);
-  }
-
-  return;
-}
-#endif
-
-#if 0
-/* @func GPS_Util_Block  ****************************************************
-**
-** Sets or unsets blocking
-** @modified 13-01-2000 to return an int
-**
-** @param [r] fd [int32] file descriptor
-** @param [r] state [int32] state=true->block state=false->non-block
-**
-** @return [int32] success
-** @@
-****************************************************************************/
-
-int32 GPS_Util_Block(int32 fd, int32 state)
-{
-  static int32 notcalled=1;
-  static int32 block;
-  static int32 noblock;
-  int32    f;
-
-  gps_errno = HARDWARE_ERROR;
-
-  if (notcalled) {
-    notcalled = 0;
-    if ((f=fcntl(fd,F_GETFL,0))==-1) {
-      GPS_Error("Util_Block: FCNTL error");
-      return 0;
-    }
-    block = f & ~O_NDELAY;
-    noblock = f |  O_NDELAY;
-  }
-
-  if (state) {
-    if (fcntl(fd,F_SETFL,block)==-1) {
-      GPS_Error("Util_Block: Error blocking");
-      return 0;
-    }
-  } else {
-    if (fcntl(fd,F_SETFL,noblock)==-1) {
-      GPS_Error("Util_Block: Error unblocking");
-      return 0;
-    }
-  }
-
-  return 1;
-}
-#endif
-
-
-/* @func GPS_Warning ********************************************************
-**
-** Prints warning if gps_warning is true
-**
-** @param [r] s [char *] warning
-**
-** @return [void]
-** @@
-****************************************************************************/
-
-void GPS_Warning(const char* s)
-{
-  if (!gps_warning) {
-    return;
-  }
-
-  fprintf(stderr,"[WARNING] %s\n",s);
-  fflush(stderr);
-
-  return;
-}
-
-
-/* @func GPS_Fatal ********************************************************
-**
-** Always prints error and exits program
-** Bad thing for a library so the library doesn't call it.
-**
-** @param [r] s [char *] fatal error
-**
-** @return [void]
-** @@
-****************************************************************************/
-
-[[noreturn]] void GPS_Fatal(const char* s)
-{
-
-  fprintf(stderr,"[FATAL] %s\n",s);
-  exit(0);
-}
-
-
-
-/* @func GPS_Error **********************************************************
-**
-** Prints Error if gps_error is true
-**
-** @param [r] s [char *] error
-**
-** @return [void]
-** @@
-****************************************************************************/
-
-void GPS_Error(const char* fmt, ...)
-{
-  va_list argp;
-  va_start(argp, fmt);
-
-  if (gps_error) {
-    fprintf(stderr, "[ERROR] ");
-    vfprintf(stderr, fmt, argp);
-    fprintf(stderr, "\n");
-  }
-
-  va_end(argp);
-  return;
-}
-
-
-/* @func GPS_Enable_Error ***************************************************
-**
-** Enable error message printing
-**
-** @return [void]
-** @@
-****************************************************************************/
-
-void GPS_Enable_Error()
-{
-  gps_error = 1;
-  return;
-}
-
-
-
-/* @func GPS_Enable_Warning ***************************************************
-**
-** Enable warning message printing
-**
-** @return [void]
-** @@
-****************************************************************************/
-
-void GPS_Enable_Warning()
-{
-  gps_warning = 1;
-  return;
-}
-
-
-
-/* @func GPS_Disable_Error ***************************************************
-**
-** Disable error message printing
-**
-** @return [void]
-** @@
-****************************************************************************/
-
-void GPS_Disable_Error()
-{
-  gps_error = 0;
-  return;
-}
-
-
-
-/* @func GPS_Disable_Warning ***********************************************
-**
-** Disable warning message printing
-**
-** @return [void]
-** @@
-****************************************************************************/
-
-void GPS_Disable_Warning()
-{
-  gps_warning = 0;
-  return;
-}
-
-
-
-/* @func GPS_User ********************************************************
-**
-** Prints a message if gps_user is true
-**
-** @param [r] s [char *] message
-**
-** @return [void]
-** @@
-****************************************************************************/
-
-void GPS_User(const char* fmt, ...)
-{
-  va_list  argp;
-  va_start(argp, fmt);
-
-  if (gps_user) {
-    vfprintf(stdout, fmt, argp);
-    fflush(stdout);
-  }
-
-  va_end(argp);
-}
-
-/* @func GPS_Disable_User ***********************************************
-**
-** Disable message printing
-**
-** @return [void]
-** @@
-****************************************************************************/
-
-void GPS_Disable_User()
-{
-  gps_user = 0;
-  return;
-}
-
-
-/* @func GPS_Enable_User ***********************************************
-**
-** Disable warning message printing
-**
-** @return [void]
-** @@
-****************************************************************************/
-
-void GPS_Enable_User()
-{
-  gps_user = 1;
-  return;
-}
-
-
-/* @func GPS_Diagnose ********************************************************
-**
-** Prints bytes read from gps if gps_show_bytes is set
-**
-** @param [r] cs [int32] byte read
-**
-** @return [void]
-** @@
-****************************************************************************/
-
-void GPS_Diagnose(int32 c)
-{
-  if (!gps_show_bytes) {
-    return;
-  }
-
-  fprintf(stdout,"%d\n",(int)c);
-  fflush(stdout);
-
-  return;
-}
-
-void GPS_Diag(const char* fmt, ...)
-{
-  va_list argp;
-  va_start(argp, fmt);
-
-  if (gps_show_bytes) {
-    vfprintf(stdout, fmt, argp);
-  }
-  va_end(argp);
-  return;
-
-}
-
-/* @func GPS_Enable_Diagnose ***********************************************
-**
-** Enable diagnosis mode
-**
-** @return [void]
-** @@
-****************************************************************************/
-
-void GPS_Enable_Diagnose()
-{
-  gps_show_bytes = 1;
-  return;
-}
-
-
-
-/* @func GPS_Disable_Diagnose ***********************************************
-**
-** Disable diagnosis mode
-**
-** @return [void]
-** @@
-****************************************************************************/
-
-void GPS_Disable_Diagnose()
-{
-  gps_show_bytes = 0;
-  return;
-}